#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> finalPrices(vector<int>& prices) {
        vector<int> v1;
        for (int i = 0; i < prices.size(); i++)
        {
            int m = prices[i];
            for (int j = i + 1; j < prices.size(); j++)
            {
                if (prices[j] <= m && m - prices[j] >= 0)
                {
                    m -= prices[j];
                    break;
                }
            }
            v1.push_back(m);
        }

        return v1;
    }
};